package com.collectplus.express.logic;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.collectplus.express.BaseActivity2;
import com.collectplus.express.BaseFragment;
import com.collectplus.express.MainActivity;
import com.collectplus.express.R;
import com.collectplus.express.app.AppWebDialog;
import com.collectplus.express.app.Intents;
import com.collectplus.express.banner.Banner;
import com.collectplus.express.banner.BannerConfig;
import com.collectplus.express.banner.Transformer;
import com.collectplus.express.banner.loader.GlideImageLoader;
import com.collectplus.express.menu.WebViewActivity;
import com.collectplus.express.model.BannerBean;
import com.collectplus.express.model.CalculateProvinceBean;
import com.collectplus.express.model.Const;
import com.collectplus.express.model.IdCardInfoBean;
import com.collectplus.express.model.ParcelReceiveReachedStationBean;
import com.collectplus.express.model.PassportDetailBean;
import com.collectplus.express.model.ReceiverBean;
import com.collectplus.express.model.SameCityHistoryBean;
import com.collectplus.express.model.ShareBean;
import com.collectplus.express.model.UserBean;
import com.collectplus.express.parcel.ParcelDetailActivity;
import com.collectplus.express.parcel.ParcelWaitTakeActivity;
import com.collectplus.express.parcel.fragment.ParcelReceiveWaitFragment;
import com.collectplus.express.passport.NewPassportCollectingActivity;
import com.collectplus.express.self.SelfFormInfoActivity;
import com.collectplus.express.self.SelfServicePointActivity;
import com.collectplus.express.wheelview.listener.OnOptionsSelectChangeListener;
import com.collectplus.express.wheelview.view.WheelOptions;
import com.collectplus.express.wxapi.WXshare;
import com.shouhuobao.bhi.receiver.ReceiverLocationAdapter;
import com.shouhuobao.bhi.receiver.ReceiverNewFragment;
import com.shouhuobao.home.CalculatePriceActivity;
import com.shouhuobao.identity.AuthenticationActivity;
import com.shouhuobao.samecity.SameCityFormActivity;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;

import droid.frame.activity.ActivityMgr;
import droid.frame.app.Callback;
import droid.frame.push.PushInterface;
import droid.frame.ui.dialog.AppDialog;
import droid.frame.ui.dialog.BaseDialog;
import droid.frame.umeng.UMeng;
import droid.frame.utils.Android;
import droid.frame.utils.GlideUtil;
import droid.frame.utils.android.Alert;
import droid.frame.utils.http.BitmapUtils;
import droid.frame.utils.lang.Str;
import droid.frame.utils.lang.StringReplaceUtil;
import droid.frame.view.TextWatcherExt;
import droid.frame.view.ViewPagerExt;

import static droid.frame.utils.lang.Str.isNotEmpty;

/**
 * @author coffee<br>
 * 2015-6-12下午5:00:44
 */
@SuppressLint("InflateParams")
public class DialogMgr {

    // /**
    // * 提示对话框 只显示一次
    // *
    // * @param context
    // * @param type
    // * @param url
    // */
    // public static void showOnceDialog(Activity context, final int type, final View.OnClickListener listener) {
    // // 首次访问
    // if (SharedPref.isFirstOpen(type) == false) {
    // return;
    // } else {
    // String url = "";
    // // 显示服务区
    // if (type == 1) {
    // url = AppConfig.getServiceInfoUrl();
    // }
    // AppWebDialog dialog = DialogMgr.showWebview(context, url);
    // dialog.setOnCancelListener(new OnCancelListener() {
    // @Override
    // public void onCancel(DialogInterface dialog) {
    // SharedPref.setFirstOpen(type, false);
    // if (listener != null) {
    // listener.onClick(null);
    // }
    // }
    // });
    // }
    //
    // }
    private static int parcelWeight = 3;
    private static int sameCityParcelWeight = 5;

    /**
     * 只支持图片链接
     *
     * @param context
     * @param url
     * @return
     */
    public static AppWebDialog showWebview(Activity context, String url) {
        if (url != null && (url.endsWith(".jpg") || url.endsWith(".png"))) {
            AppWebDialog dialog = new AppWebDialog(context);
            dialog.showImage(url);
            return dialog;
        } else {
            // showWebview(context, url);
            AppWebDialog dialog = new AppWebDialog(context);
            // 下面这句竟然无效，原因是所选区域非Outside...
            dialog.setCanceledOnTouchOutside(true);
            dialog.showWebView(url);
            return dialog;
        }
    }

    /**
     * 显示取货密码和二维码
     */
    public static BaseDialog showPasswordDialog(final Activity context, String number, String picUrl) {
        final BaseDialog dialog = new BaseDialog(context);
        dialog.setContentView(R.layout.collect_point_password);
        ImageView mPasswordPic = (ImageView) dialog.findViewById(R.id.password_pic);
        TextView mPasswordNumber = (TextView) dialog.findViewById(R.id.password_number);
        mPasswordNumber.setText("密码:" + number);
        // 请求二维码图片
        if (!TextUtils.isEmpty(picUrl)) {
            AppLogic.getInstance().loadImage(picUrl, mPasswordPic, false);
        }
        dialog.show();
        return dialog;
    }

    /**
     * 从passport详情页分享到微信或朋友圈
     *
     * @param context
     * @param share
     * @return
     */
    public static BaseDialog showWeixinShare(final BaseActivity2 context, final ShareBean share, final String orderId) {
        final BaseDialog dialog = new BaseDialog(context);
        dialog.setContentView(R.layout.share_weixin);
        // 分享给微信、朋友圈--父布局
        View layout = dialog.findViewById(R.id.share_layout);
        // 分享微信
        final View shareWx = dialog.findViewById(R.id.share_weixin);
        // 分享朋友圈
        final View shareFriend = dialog.findViewById(R.id.share_friend);
        layout.setVisibility(View.VISIBLE);
        //
        final String title = share.getTitle();
        final String desc = share.getContent();
        final String url = share.getUrl();
        final Bitmap bitmap = share.getPicBitmap();
        //
        shareWx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (AppLogic.isInstallWXApp(context) == false) {
                    Alert.toast("微信未安装");
                } else {
                    WXshare share = new WXshare(context);
                    share.sendMessage(0, title, desc, bitmap, url);
                }
            }
        });
        shareFriend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (AppLogic.isInstallWXApp(context) == false) {
                    Alert.toast("微信未安装");
                } else {
                    WXshare share = new WXshare(context);
                    share.sendMessage(1, title, desc, bitmap, url);
                }
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * app通用的信息显示框
     */
    public static AppDialog showAppMessage(final Activity context, String message) {
        AppDialog dialog = new AppDialog(context);
        dialog.setContent(message);
        dialog.setConfirmClickListener("我知道了", null);
        dialog.show();
        return dialog;
    }

    /**
     * 显示物品类型
     *
     * @param context
     * @return
     * @author coffee
     */
    @SuppressLint("WrongConstant")
    public static PopupWindow showGoodsType(final SelfFormInfoActivity context, View atLocationView, String type) {
        final View layout = LayoutInflater.from(context).inflate(R.layout.self_goods_type, null);
        //
        final PopupWindow popwin = createPopupWindow(context, layout);
        popwin.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popwin.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popwin.showAtLocation(atLocationView, Gravity.RIGHT | Gravity.BOTTOM, 0, 0);

        final TextView typeText = (TextView) layout.findViewById(R.id.choose_goods_type);
        for (int i = 1; i <= 6; i++) {
            int resId = context.getResources().getIdentifier("goods_type_" + i, "id", context.getPackageName());
            final TextView item = (TextView) layout.findViewById(resId);
            if ((Str.isEmpty(type) && i == 1) || type.split(" ")[0].equals(item.getText())) {
                item.setTextColor(context.getResources().getColor(R.color.app_font_1));
                item.setBackgroundResource(R.drawable.self_goodstype_item2);
                item.setPressed(true);
            } else {
                item.setTextColor(context.getResources().getColor(R.color.app_font_2));
                item.setBackgroundResource(R.drawable.self_goodstype_item1);
            }
            item.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // context.onGoodsTypeSelect(((TextView) v).getText());
                    // popwin.dismiss();
                    item.setTextColor(context.getResources().getColor(R.color.app_font_1));
                    item.setBackgroundResource(R.drawable.self_goodstype_item2);
                    typeText.setVisibility(View.VISIBLE);
                    typeText.setText(((TextView) v).getText());
                    layout.findViewById(R.id.weight_item).setVisibility(View.VISIBLE);
                    layout.findViewById(R.id.type_item1).setVisibility(View.GONE);
                    layout.findViewById(R.id.type_item2).setVisibility(View.GONE);
                    UMeng.click(context, "selfBag_" + item.getText().toString() + "_click");

                }
            });
        }
        //选择重量,默认重量为3公斤
        final EditText weightET = (EditText) layout.findViewById(R.id.weight_et);
        final TextView weightTipTV = (TextView) layout.findViewById(R.id.weight_tip_tv);
        weightET.setFocusable(false);
        weightET.setFocusableInTouchMode(false);
        weightET.clearFocus();
        weightTipTV.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(context, WebViewActivity.class);
                intent.putExtra("title", "价格说明");
                context.startActivity(intent);
            }
        });
        if (Str.isEmpty(type)) {
            weightTipTV.setVisibility(View.INVISIBLE);
        } else {
            try {
                parcelWeight = Integer.valueOf(type.split(" ")[1].replace("kg", ""));
            } catch (Exception e) {
                e.printStackTrace();
                parcelWeight = 3;
            }
            if (parcelWeight <= 3) {
                weightTipTV.setVisibility(View.INVISIBLE);
            } else {
                weightTipTV.setVisibility(View.VISIBLE);
            }
            weightET.setText(parcelWeight + "");
        }
        //重量减法
        layout.findViewById(R.id.reduce_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (parcelWeight <= 1) {
                    parcelWeight = 1;
                } else {
                    parcelWeight--;
                }
                weightET.setText(parcelWeight + "");
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        //重量加法，上限为99公斤
        layout.findViewById(R.id.add_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (parcelWeight >= 99) {
                    parcelWeight = 99;
                } else {
                    parcelWeight++;
                }
                weightET.setText(parcelWeight + "");
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        weightET.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Android.showSoftInput(context, weightET);
                weightET.setFocusable(true);
                weightET.setFocusableInTouchMode(true);
                weightET.requestFocus();
                weightET.setSelection(weightET.getText().length());
            }
        });
        weightET.addTextChangedListener(new TextWatcherExt() {
            @Override
            public void afterTextChanged(Editable editable) {
                if (Str.isNotEmpty(editable)) {
                    if (editable.toString().length() == 2 && editable.toString().startsWith("0")) {
                        parcelWeight = Integer.valueOf(editable.toString().substring(1));
                        weightET.setText(parcelWeight + "");
                        try {
                            weightET.setSelection(weightET.getText().length());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } else {
                        parcelWeight = Integer.valueOf(editable.toString());
                    }
                    if (parcelWeight <= 3) {
                        weightTipTV.setVisibility(View.INVISIBLE);
                    } else {
                        weightTipTV.setVisibility(View.VISIBLE);
                    }
                } else {
                    parcelWeight = 3;
                    weightTipTV.setVisibility(View.INVISIBLE);
                }
            }
        });
        //点击输入重量布局
        layout.findViewById(R.id.weight_layout).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Android.showSoftInput(context, weightET);
                weightET.setFocusable(true);
                weightET.setFocusableInTouchMode(true);
                weightET.requestFocus();
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        // 确认重量
        layout.findViewById(R.id.weight_confirm).

                setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (Str.isEmpty(weightET.getText().toString()) || weightET.getText().toString().equals("0")) {
                            parcelWeight = 3;
                        }
                        context.onGoodsTypeSelect(typeText.getText(), parcelWeight + "");
                        Android.hideSoftInput(context);
                        parcelWeight = 3;
                        popwin.dismiss();
                    }
                });
        layout.findViewById(R.id.title_right).

                setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        parcelWeight = 3;
                        popwin.dismiss();
                    }
                });
        return popwin;
    }

    public static PopupWindow createPopupWindow(final Activity context, View layout) {
        PopupWindow mpWindow = new PopupWindow(layout, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        mpWindow.setOutsideTouchable(true);// popupwindow设置触摸可消失
        // ColorDrawable dw = new ColorDrawable(android.R.color.black);
        // dw.setAlpha(180);
        // mpWindow.setBackgroundDrawable(dw); // 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ，设置其他控件变化等操作
        // popupwindow显示方式
        // mpWindow.showAtLocation(context.findViewById(R.id.address_call), Gravity.RIGHT | Gravity.BOTTOM, 0, 0);
        mpWindow.setFocusable(true);// 这里必须设置为true才能点击区域外或者消失
        mpWindow.setTouchable(true);// 这个控制PopupWindow内部控件的点击事件
        mpWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mpWindow.setOutsideTouchable(true);
        mpWindow.setAnimationStyle(R.style.popup_window_bottom2top);
        mpWindow.update();
        // 设置背景变暗
        final Window window = context.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.alpha = 0.7f;
        window.setAttributes(lp);
        window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        // context.findViewById(android.R.id.content).setAlpha(0.7F);
        mpWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                resetWindowAttribute(context);
            }
        });
        return mpWindow;
    }

    private static void resetWindowAttribute(Activity context) {
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.alpha = 1f;
        context.getWindow().setAttributes(lp);
        context.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    }

    /**
     * 快递员取消下单以后通知用户
     */
    public static void showOrderCancelTip(int reasonType) {
        final Activity main = ActivityMgr.peek();
        if (main == null) {
            return;
        }
        final AppDialog mCancelDialog = new AppDialog(main);
        // mCancelDialog.setCanceledOnTouchOutside(false); //无效,需要在show之后设置
        // mCancelDialog.setTitle("快递员取消了您的订单");
        String reason = "";
        if (reasonType == 1) {
            reason = "您好，快递员未能与您取得联系，请检查您的电话是否畅通。如有需要，请再次下单。";
        } else {
            reason = "您好，快递员与您协商一致，取消了订单。如有需要，请再次下单。 ";
        }
        mCancelDialog.setTitle(reason, Gravity.LEFT);

        mCancelDialog.setCancelClickListener("我知道了", new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(main, MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                main.startActivity(intent);
                //
                mCancelDialog.cancel();
            }
        });
        mCancelDialog.show();
        mCancelDialog.setCanceledOnTouchOutside(false);// show之前设置无效
        mCancelDialog.setCancelable(false);// 点back键也无效
    }

    public static Rect locateView(View v) {
        int[] loc_int = new int[2];
        if (v == null)
            return null;
        try {
            v.getLocationOnScreen(loc_int);
        } catch (NullPointerException npe) {
            // Happens when the view doesn't exist on screen anymore.
            return null;
        }
        Rect location = new Rect();
        location.left = loc_int[0];
        location.top = loc_int[1];
        location.right = location.left + v.getWidth();
        location.bottom = location.top + v.getHeight();
        return location;
    }

    public static void showOrderCancelDialog3(final Activity context, final Serializable orderId, final Serializable parcelId, int parcelStatus) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("确定要取消该订单?");
        //已支付取消订单
        if (parcelStatus == Const.ParcelStatus.payed) {
            dialog.setContent("您支付的金额或邮票将在2个工作日内退回（非邮票商城购买邮票不退还）");
        }
        dialog.setCancelClickListener("取消订单", new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((ParcelDetailActivity) context).showLoadingDialog(null);
                AppHttp.getInstance().orderCancel(orderId, parcelId, 11, null);
                dialog.dismiss();
            }
        });
        dialog.setConfirmClickListener("不取消了", null);
        dialog.show();
    }

    /**
     * 上门时取消订单
     *
     * @param context
     */
    public static BaseDialog showOrderCancelDialog4(final BaseActivity2 context, final Serializable orderId, OnClickListener onClickListener, String price, int type) {
        final BaseDialog dialog = new BaseDialog(context);
        dialog.setContentView(R.layout.dialog_parcel_detail_cancel_order);
        TextView cancelTheOrderContentTV = (TextView) dialog.findViewById(R.id.cancel_the_order_content_tv);
        if (type == 1) {
            cancelTheOrderContentTV.setText("您确定取消订单吗？取消订单将扣除上门费" + price + "元，其他费用或邮票会原路退回至您的账户。如有疑问咨询客服：400 617 1949");
        } else if (type == 2) {
            cancelTheOrderContentTV.setText("您确定取消订单吗？5分钟内免责取消，超过5分钟取消将扣除5元配送费用。如有疑问咨询客服：400 617 1949");
        }
        dialog.findViewById(R.id.exception1_cb).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception_item1).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception2_cb).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception_item2).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception3_cb).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception_item3).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.exception_item4).setOnClickListener(onClickListener);
        //确认取消
        dialog.findViewById(R.id.submit_tv).setOnClickListener(onClickListener);
        dialog.findViewById(R.id.cancel_tv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 拨打电话弹出的对话框：客服
     *
     * @param context
     * @param serviceTime 服务时间
     * @author huxindan
     */
    public static void showPhoneDialog(final Activity context, String serviceTime) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("呼叫 400-617-1949");
        if (serviceTime == null) {
            dialog.setContent(context.getResources().getString(R.string.service_phone));
        } else {
            dialog.setContent(serviceTime);
        }
        dialog.setConfirmClickListener("呼叫", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:400-617-1949"));
                context.startActivity(intent);
            }
        });
        dialog.setCancelClickListener("取消", null);
        dialog.show();
    }

    /**
     * 在退出登录时弹出的提示
     *
     * @param context
     */
    public static void showBackHome(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("是否退出登录？");
        dialog.setConfirmClickListener("确定", new OnClickListener() {
            @Override
            public void onClick(View v) {
                context.finish();
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("取消", null);
        dialog.show();
    }

    /**
     * 寄件人地址、上门地址选取
     */
    public static PopupWindow showLocationList(final ReceiverNewFragment fragment, ArrayList<SameCityHistoryBean> items, int anchor) {
        if (items == null) {
            return null;
        }
        Activity context = fragment.getActivityContext();
        View layout = LayoutInflater.from(context).inflate(R.layout.receiver_location_popupwin, null);
        final ReceiverLocationAdapter adapter = new ReceiverLocationAdapter(items, context);
        // LinearLayout parent = (LinearLayout) layout.findViewById(R.id.parent);
        // for (int i = 0; i < adapter.getCount(); i++) {
        // View child = adapter.getView(i, null, parent);
        // parent.addView(child);
        // final int position = i;
        // child.setOnClickListener(new View.OnClickListener() {
        // @Override
        // public void onClick(View v) {
        // LocationBean location = adapter.getItem(position);
        // fragment.onSelectLocation(location.getAddress());
        //
        // }
        // });
        // }

        final PopupWindow mpWindow = createPopupWindow(context, layout);
        ListView listview = (ListView) layout.findViewById(R.id.listview);
        listview.setAdapter(adapter);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SameCityHistoryBean location = adapter.getItem(position);
                fragment.onSelectLocation(location);
                mpWindow.dismiss();
            }
        });
        mpWindow.showAtLocation(context.findViewById(anchor), Gravity.RIGHT | Gravity.BOTTOM, 0, 0);
        //
        layout.findViewById(R.id.content).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mpWindow.dismiss();
            }
        });
        layout.findViewById(R.id.title_right).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mpWindow.dismiss();
            }
        });
        return mpWindow;
    }

    /**
     * 退出
     *
     * @param context
     * @return
     */
    public static AppDialog showQuit(final Activity context, final Callback callback) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("是否退出登录？");
        dialog.setConfirmClickListener("取消", null);
        dialog.setCancelClickListener("确定", new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 退出登录
                try {
                    PushInterface.logout();
                    AppCache.setUser(null);
                    //
                } catch (Exception e) {
                    e.printStackTrace();
                }
                dialog.dismiss();
                if (callback != null) {
                    callback.onDialogDismiss();
                }
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 登录获取验证码
     */
    //    public static BaseDialog getLoginCode(final int type, final BaseActivity2 context, String image, final String loginPhone) {
    //        final BaseDialog dialog = new BaseDialog(context);
    //        dialog.setContentView(R.layout.login_code);
    //        //验证码图片
    //        ImageView loginCodeIV = (ImageView) dialog.findViewById(R.id.login_code_iv);
    //        loginCodeIV.setImageBitmap(BitmapUtils.base64ToBitmap(image));
    //        loginCodeIV.setOnClickListener(new OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                ((LoginActivity) context).getImageCode(loginPhone);
    //            }
    //        });
    //        dialog.findViewById(R.id.close_iv).setOnClickListener(new OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                dialog.dismiss();
    //            }
    //        });
    //        // 输入验证码布局
    //        final CodeLinearLayout loginInputLL = (CodeLinearLayout) dialog.findViewById(R.id.login_input_layout);
    //        loginInputLL.setCallback(new Callback() {
    //            @Override
    //            public void execute(Object... result) {
    //                String code = loginInputLL.getText();
    //                if (code.length() == 4) {
    //                    ((LoginActivity) context).getSMSNumCode(type, code);
    //                    dialog.dismiss();
    //                }
    //            }
    //        });
    //        dialog.findViewById(R.id.input_ll).setOnClickListener(new OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Android.toggleSoftInput(context);
    //            }
    //        });
    //        dialog.show();
    //        return dialog;
    //    }

    /**
     * 我的包裹路由分享
     */
    @SuppressLint("WrongConstant")
    public static void parcelRouteShare(final Activity context, String parcelId) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_parcel_share, null);
        final PopupWindow popWindow = createPopupWindow(context, view);
        popWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popWindow.setAnimationStyle(0);
        popWindow.showAtLocation(context.findViewById(R.id.parcel_shared_bt), Gravity.BOTTOM, 0, 0);
        final WXshare mWXshare = new WXshare(context);
        final String url = AppConfig.getServerUrl() + "static/promo/parcelRouterShare.html?parcelId=" + parcelId + "&userId=" + AppCache.getUserId();
        final String title = "Hi，我用火箭投递给你寄包裹啦！";
        final String description = "记得签收哦，点击链接查看。";
        final Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.parcel_share_logo);
        //微信好友
        view.findViewById(R.id.wx_friend_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mWXshare.shareWX(0, title, description, icon, url, null, null);
                popWindow.dismiss();
            }
        });
        //微信朋友圈
        view.findViewById(R.id.wx_circule_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mWXshare.shareWX(1, title, description, icon, url, null, null);
                popWindow.dismiss();
            }
        });
    }

    /**
     * 退出
     *
     * @param context
     * @return
     */
    public static void deleteReceiverHistory(final Activity context, final ReceiverBean receiverBean, final Callback callback) {
        final AppDialog dialog = new AppDialog(context);
        StringBuilder builder = new StringBuilder();
        builder.append("是否想将\"");
        builder.append(receiverBean.getName());
        builder.append("\"从常用联系人删除?");
        dialog.setContent(builder.toString());
        dialog.setConfirmClickListener("取消", null);
        dialog.setCancelClickListener("确定", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                if (callback != null) {
                    callback.onDialogDismiss();
                }
            }
        });
        dialog.show();
    }

    /**
     * 点击驿站头像查看图片
     */
    @SuppressLint("WrongConstant")
    public static BaseDialog showLargeStationPhoto(Activity context, String imageUrl) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.dialog_station_large_photo);
        if (!Str.isEmpty(imageUrl)) {
            GlideUtil.loadImage(context, imageUrl, 0, (ImageView) dialog.findViewById(R.id.large_photo_iv));
        }
        dialog.show();
        return dialog;
    }

    /**
     * 投递包裹完成后，进行身份认证提示
     */
    public static void showAuthenticationTips(final Activity context, final boolean isFinish, final IdCardInfoBean bean) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("投递成功!");
        dialog.setContent("根据国家政策快递实名制要求，您需要提交身份信息认证，以便后续服务不受影响。");
        dialog.setConfirmClickListener("前往提交", new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bean != null) {
                    if (bean.getStatus() >= 21) {
                        context.startActivity(new Intent(context, AuthenticationActivity.class));
                    } else {
                        AppLogic.contextToAuthenticationClass(context, bean);
                    }
                }
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("暂不实名", new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isFinish) {
                    context.finish();
                }
                dialog.dismiss();
            }
        });
        dialog.show();
    }

    /**
     * 下订单时，如果附近没有火箭侠进行提示
     */
    public static void showSubmitOrderTipsDialog(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setContent("该地区暂没有火箭侠上门服务哦，推荐选择驿站进行投递~");
        dialog.setConfirmClickListener("我再想想", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("去选择驿站", new OnClickListener() {
            @Override
            public void onClick(View v) {
                ReceiverBean cacheReceiver = AppCache.getParcelNew();
                if (null == cacheReceiver || null == cacheReceiver.getServicePoint()) {
                    return;
                }
                cacheReceiver.setVisitDoorBean(null);
                cacheReceiver.setType(1);
                AppCache.setParcelNew(cacheReceiver);
                Intent intent = new Intent(context, SelfServicePointActivity.class);
                intent.putExtra("goodsType", cacheReceiver.getServicePoint().getGoodsType());
                context.startActivity(intent);
                dialog.dismiss();
                context.finish();
            }
        });
        dialog.show();
    }

    /**
     * 显示物品类型
     *
     * @param context
     * @return
     * @author coffee
     */
    @SuppressLint("WrongConstant")
    public static PopupWindow showSameCityGoodsType(final SameCityFormActivity context, String type) {
        final View layout = LayoutInflater.from(context).inflate(R.layout.layout_samecity_goods_type, null);
        //
        final PopupWindow popwin = createPopupWindow(context, layout);
        popwin.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popwin.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popwin.showAtLocation(context.findViewById(R.id.subimt_order_bt), Gravity.RIGHT | Gravity.BOTTOM, 0, 0);

        final TextView typeText = (TextView) layout.findViewById(R.id.choose_goods_type);
        for (int i = 1; i <= 9; i++) {
            int resId = context.getResources().getIdentifier("goods_type_" + i, "id", context.getPackageName());
            final TextView item = (TextView) layout.findViewById(resId);
            if ((Str.isEmpty(type) && i == 1) || type.split(" ")[0].equals(item.getText())) {
                item.setTextColor(context.getResources().getColor(R.color.app_font_1));
                item.setBackgroundResource(R.drawable.self_goodstype_item2);
            } else {
                item.setTextColor(context.getResources().getColor(R.color.app_font_2));
                item.setBackgroundResource(R.drawable.self_goodstype_item1);
            }
            item.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    item.setTextColor(context.getResources().getColor(R.color.app_font_1));
                    item.setBackgroundResource(R.drawable.self_goodstype_item2);
                    // context.onGoodsTypeSelect(((TextView) v).getText());
                    // popwin.dismiss();
                    typeText.setVisibility(View.VISIBLE);
                    typeText.setText(((TextView) v).getText());
                    layout.findViewById(R.id.weight_item).setVisibility(View.VISIBLE);
                    layout.findViewById(R.id.type_item1).setVisibility(View.GONE);
                    layout.findViewById(R.id.type_item2).setVisibility(View.GONE);
                    layout.findViewById(R.id.type_item3).setVisibility(View.GONE);
                }
            });
        }
        //选择重量,默认重量为5公斤
        final EditText weightET = (EditText) layout.findViewById(R.id.weight_et);
        final TextView weightTipTV = (TextView) layout.findViewById(R.id.weight_tip_tv);
        weightET.setFocusable(false);
        weightET.setFocusableInTouchMode(false);
        weightET.clearFocus();
        weightTipTV.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(context, WebViewActivity.class);
                intent.putExtra("title", "计价规则");
                context.startActivity(intent);
            }
        });
        if (Str.isEmpty(type)) {
            weightTipTV.setVisibility(View.INVISIBLE);
        } else {
            try {
                sameCityParcelWeight = Integer.valueOf(type.split(" ")[1].replace("kg", ""));
            } catch (Exception e) {
                e.printStackTrace();
                sameCityParcelWeight = 5;
            }
            if (sameCityParcelWeight <= 5) {
                weightTipTV.setVisibility(View.INVISIBLE);
            } else {
                weightTipTV.setVisibility(View.VISIBLE);
            }
            weightET.setText(sameCityParcelWeight + "");
        }
        //重量减法
        layout.findViewById(R.id.reduce_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (sameCityParcelWeight <= 1) {
                    sameCityParcelWeight = 1;
                } else {
                    sameCityParcelWeight--;
                }
                weightET.setText(sameCityParcelWeight + "");
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        //重量加法，上限为99公斤
        layout.findViewById(R.id.add_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (sameCityParcelWeight >= 99) {
                    sameCityParcelWeight = 99;
                } else {
                    sameCityParcelWeight++;
                }
                weightET.setText(sameCityParcelWeight + "");
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        weightET.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Android.showSoftInput(context, weightET);
                weightET.setFocusable(true);
                weightET.setFocusableInTouchMode(true);
                weightET.requestFocus();
                weightET.setSelection(weightET.getText().length());
            }
        });
        weightET.addTextChangedListener(new TextWatcherExt() {
            @Override
            public void afterTextChanged(Editable editable) {
                if (Str.isNotEmpty(editable)) {
                    if (editable.toString().length() == 2 && editable.toString().startsWith("0")) {
                        sameCityParcelWeight = Integer.valueOf(editable.toString().substring(1));
                        weightET.setText(sameCityParcelWeight + "");
                        try {
                            weightET.setSelection(weightET.getText().length());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } else {
                        sameCityParcelWeight = Integer.valueOf(editable.toString());
                    }
                    if (sameCityParcelWeight <= 5) {
                        weightTipTV.setVisibility(View.INVISIBLE);
                    } else {
                        weightTipTV.setVisibility(View.VISIBLE);
                    }
                } else {
                    sameCityParcelWeight = 5;
                    weightTipTV.setVisibility(View.INVISIBLE);
                }
            }
        });
        //点击输入重量布局
        layout.findViewById(R.id.weight_layout).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Android.showSoftInput(context, weightET);
                weightET.setFocusable(true);
                weightET.setFocusableInTouchMode(true);
                weightET.requestFocus();
                try {
                    weightET.setSelection(weightET.getText().length());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        // 确认重量
        layout.findViewById(R.id.weight_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Str.isEmpty(weightET.getText().toString()) || weightET.getText().toString().equals("0")) {
                    sameCityParcelWeight = 5;
                }
                context.onGoodsTypeSelect(typeText.getText(), sameCityParcelWeight + "");
                Android.hideSoftInput(context);
                sameCityParcelWeight = 5;
                popwin.dismiss();
            }
        });
        layout.findViewById(R.id.title_right).

                setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        sameCityParcelWeight = 5;
                        popwin.dismiss();
                    }
                });
        return popwin;
    }

    /**
     * passport中点击通知收件人弹出
     * 您好，我通过火箭投递送给你一个包裹，
     * 火箭侠【花名（真实姓名）（手机号）】
     * 约在10：20前将包裹送达，请凭借
     * 收件码123123
     */
    @SuppressLint("WrongConstant")
    public static BaseDialog noticeReceiverDialog(Activity context, final PassportDetailBean bean) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.dialog_passport_notice_receiver);
        String contentStr = "<font color=#3E0708>您好，我通过火箭投递送给你一个包裹，<br/> 火箭侠[{0}  {1}   {2}]<br/>约在{3}前将包裹送达，请凭借<br/>收件码</font><font color=#FF7600>{4}</font><font color=#3E0708>签收</font>";
        final TextView sendMessageTV = (TextView) dialog.findViewById(R.id.notice_content_tv);
        sendMessageTV.setText(Html.fromHtml(MessageFormat.format(contentStr, bean.getNickName(), bean.getName(), bean.getPhone(), bean.getEstimateTime(), bean.getCheckCode2())));
        //关闭dialog
        dialog.findViewById(R.id.cancel_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        //点击短信通知进行短信发送
        dialog.findViewById(R.id.sms_notice_tv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intents.sendSMSMessage(bean.getPhone(), sendMessageTV.getText().toString());
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 我的二维码
     */
    @SuppressLint("WrongConstant")
    public static BaseDialog showParcelCityWideQr(Activity context) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.dialog_parcel_city_wide_qr);
        UserBean userBean = AppCache.getUser();
        ImageView mQRcodeIV = (ImageView) dialog.findViewById(R.id.qrcode_iv);
        ((TextView) dialog.findViewById(R.id.user_name_tv)).setText(userBean.getName());
        if (Str.isNotEmpty(userBean.getPhone())) {
            ((TextView) dialog.findViewById(R.id.user_mobile_tv)).setText(StringReplaceUtil.idCardReplaceWithStar(userBean.getPhone(), 3, 4, "*"));
        }
        if (isNotEmpty(userBean.getQrCodeUrl())) {
            mQRcodeIV.setImageBitmap(BitmapUtils.base64ToBitmap(userBean.getQrCodeUrl()));
        } else {
            //            AppHttp.getInstance().getUserQRcode();
        }
        dialog.show();
        return dialog;
    }

    /**
     * 春节不能下单提示
     */
    public static BaseDialog showSpringTips(final Activity context) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.layout_spring_tip);
        dialog.setCanceledOnTouchOutside(false);
        dialog.findViewById(R.id.confirm_iv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.finish();
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 代收-----确认取走包裹
     */
    public static void confirmTake(final Activity context, int total) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setContent("确认取走该" + total + "个包裹？");
        dialog.setConfirmClickListener("确定", new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((ParcelWaitTakeActivity) context).pcicUpParcel();
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("取消", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }

    /**
     * 代收-----确认取走包裹
     */
    public static void confirmReceiveParcelTake(final BaseFragment context, final ParcelReceiveReachedStationBean item, final int position) {
        final AppDialog dialog = new AppDialog(context.getActivityContext());
        dialog.setContent("确认取走该" + item.getParcels().size() + "个包裹？");
        dialog.setConfirmClickListener("确定", new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((ParcelReceiveWaitFragment) context).pickUpParcel(item, position);
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("取消", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }

    /**
     * 代收-----他人代收重要提示
     */
    public static BaseDialog othersCollectingDialog(final BaseActivity2 context, String code) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.others_collecting_dialog);
        if (Str.isNotEmpty(code) && code.length() == 4) {
            for (int i = 1; i <= code.length(); i++) {
                TextView codeTV = (TextView) dialog.findViewById(context.getResources().getIdentifier("code_tv_" + i, "id", context.getPackageName()));
                codeTV.setText(code.charAt(i - 1) + "");
            }
        }
        dialog.findViewById(R.id.share_other_collecting_btn).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((NewPassportCollectingActivity) context).otherCollectingShare();
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 同城-----是否需要收件人通过收件码签收包裹
     */
    public static BaseDialog sameCityReceiverCodeSelector(final Activity context, boolean isNeed) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        try {
            dialog.setContentView(R.layout.same_city_receiver_code);
            final Banner banner = (Banner) dialog.findViewById(R.id.banner);
            TextView mDoWithout = (TextView) dialog.findViewById(R.id.do_without);
            TextView mNeed = (TextView) dialog.findViewById(R.id.need);
            ArrayList<BannerBean> items = new ArrayList<>();
            BannerBean bannerBean = new BannerBean();
            bannerBean.setImgRes(R.drawable.samecity_receive_code_tip_1);
            BannerBean bannerBean1 = new BannerBean();
            bannerBean1.setImgRes(R.drawable.samecity_receive_code_tip_2);
            items.add(bannerBean);
            items.add(bannerBean1);
            //需要
            if (isNeed) {
                mNeed.setBackgroundResource(R.drawable.self_goodstype_item2);
                mNeed.setTextColor(context.getResources().getColor(R.color.app_font_1));
                mDoWithout.setBackgroundResource(R.drawable.self_goodstype_item1);
                mDoWithout.setTextColor(context.getResources().getColor(R.color.app_font_2));
            } else {//不需要
                mNeed.setBackgroundResource(R.drawable.self_goodstype_item1);
                mNeed.setTextColor(context.getResources().getColor(R.color.app_font_2));
                mDoWithout.setBackgroundResource(R.drawable.self_goodstype_item2);
                mDoWithout.setTextColor(context.getResources().getColor(R.color.app_font_1));
            }
            mDoWithout.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    ((SameCityFormActivity) context).setReceiveCodeStatus(false);
                    banner.stopAutoPlay();
                    dialog.dismiss();
                }
            });
            mNeed.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    ((SameCityFormActivity) context).setReceiveCodeStatus(true);
                    banner.stopAutoPlay();
                    dialog.dismiss();
                }
            });
            //设置banner样式
            banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
            //设置banner加载器
            banner.setImageLoader(new GlideImageLoader());
            //设置图片集合
            banner.setBannerList(items);
            //设置banner动画效果
            banner.setBannerAnimation(Transformer.Default);
            //设置自动轮播，默认为true
            banner.isAutoPlay(true);
            //设置轮播时间
            banner.setDelayTime(5000);
            //设置指示器位置（当banner模式中有指示器时）
            banner.setIndicatorGravity(BannerConfig.CENTER);
            //banner设置方法全部调用完毕时最后调用
            banner.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
        dialog.show();
        return dialog;
    }

    /**
     * 同城-----没有火箭侠可接单
     */
    public static void noCourierCnt(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setContent("附近暂无火箭侠可接单，可联系400-617-1949人工调度");
        dialog.setConfirmClickListener("立即联系", new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intents.dialOrCall("400-617-1949");
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("取消", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }

    /**
     * 智能输入步骤提示
     *
     * @param context
     * @return
     */
    public static BaseDialog showBrainpowerInputTip(Activity context) {
        final BaseDialog dialog = new BaseDialog(context, R.style.app_dialog_theme1);
        dialog.setContentView(R.layout.layout_show_brainpower_input);
        final ViewPagerExt viewPagerExt = (ViewPagerExt) dialog.findViewById(R.id.view_pager);
        final ViewGroup stateLayout = (ViewGroup) dialog.findViewById(R.id.dot_layout);
        dialog.findViewById(R.id.close_iv).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        ArrayList<View> pages = new ArrayList<View>();
        for (int i = 1; i <= 3; i++) {
            ImageView imageView = new ImageView(context);
            int drawableRes = context.getResources().getIdentifier("brainpower_input_" + i, "drawable", context.getPackageName());
            imageView.setImageResource(drawableRes);
            pages.add(imageView);
        }
        viewPagerExt.setViewItems(pages, false);
        stateLayout.removeAllViews();
        for (int i = 0; i < 3; i++) {
            ImageView child = (ImageView) LayoutInflater.from(context).inflate(R.layout.viewpager_dot, stateLayout, false);
            if (i == 0) {
                child.setImageResource(R.drawable.dot_dark_3);
            } else {
                child.setImageResource(R.drawable.dot_light_3);
            }
            stateLayout.addView(child);
        }
        viewPagerExt.addOnPageChangeListener(viewPagerExt.new ViewPageChangeListener() {
            public void onPageSelected(int position) {
                int childCount = viewPagerExt.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    ImageView child = (ImageView) stateLayout.getChildAt(i);
                    if (position == i) {
                        child.setImageResource(R.drawable.dot_dark_3);
                    } else {
                        child.setImageResource(R.drawable.dot_light_3);
                    }
                }
            }
        });
        dialog.show();
        return dialog;
    }

    /**
     * 快捷寄件通道
     */
    public static void callCenter(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.findViewById(R.id.app_dialog_title).setPadding(0, 0, 0, 0);
        dialog.setContent("400-617-1949");
        dialog.setConfirmClickListener("呼叫", new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intents.dialOrCall("400-617-1949");
                dialog.dismiss();
            }
        });
        dialog.setCancelClickListener("取消", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }

    /**
     * 快捷寄件通道不在客服服务时间段
     */
    public static void notCallCenter(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.findViewById(R.id.app_dialog_title).setPadding(0, 0, 0, 0);
        dialog.setContent("电话客服工作时间9:00-20:00，非工作时间请关注火箭投递（HJtoudi）公众号给客服留言，我们会尽快给您回复！");
        dialog.setCancelClickListener("知道了", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
    /**
     * 附近没用火箭侠或不在服务区的提示
     */
    public static void notNearByCourierTips(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.findViewById(R.id.app_dialog_title).setPadding(0, 0, 0, 0);
        dialog.setContent(" 您当前不在火箭投递服务区域哦，详情请咨询客服：4006171949");
        dialog.setCancelClickListener("知道了", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
    /**
     * 计算器选择省
     */
    @SuppressLint("WrongConstant")
    public static void calculateSelectProvincePopWin(final Activity context, View bottom, final List<CalculateProvinceBean> options1Items,
                                                     final ArrayList<ArrayList<String>> options2Items,
                                                     List<List<List<CalculateProvinceBean>>> options3Items) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_calculate_select_city, null);
        LinearLayout optionsPicker = view.findViewById(R.id.optionspicker);
        final WheelOptions wheelOptions = new WheelOptions(optionsPicker, false);
        wheelOptions.setPicker(options1Items, options2Items, options3Items);
        wheelOptions.setTextContentSize(20);
        wheelOptions.setCyclic(false, false, false);
        final PopupWindow popWindow = createPopupWindow(context, view);
        popWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popWindow.setAnimationStyle(0);
        popWindow.showAtLocation(bottom, Gravity.BOTTOM, 0, 0);
        wheelOptions.setOptionsSelectChangeListener(new OnOptionsSelectChangeListener() {
            @Override
            public void onOptionsSelectChanged(int options1, int options2, int options3) {
                String tx = options1Items.get(options1).getPickerViewText();

            }
        });
        view.findViewById(R.id.btnCancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popWindow.dismiss();
            }
        });
        view.findViewById(R.id.btnSubmit).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int[] items = wheelOptions.getCurrentItems();
                String province = options1Items.get(items[0]).getName();
                String city = "";
                if (options2Items != null) {
                    city = options1Items.get(items[0]).getCityList().get(items[1]).getName();
                }
                ((CalculatePriceActivity) context).setAddressData(options2Items == null ? 2 : 1, province, city);
                popWindow.dismiss();
            }
        });
    }
    /**
     * 获取火箭侠数量定位失败
     */
    public static void getNotLocation(final Activity context) {
        final AppDialog dialog = new AppDialog(context);
        dialog.setTitle("定位失败");
        dialog.setContent("请检查网络和是否开通定位权限，如果均无问题请重启app尝试！");
        dialog.setCancelClickListener("知道了", new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }
}
